package com.ky.pro.java.rpc.demo.provider.component;

import com.ky.pro.java.rpc.core.api.RpcfxResolver;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class DemoResolver<T> implements RpcfxResolver<T>, ApplicationContextAware {

    private ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
    }

    @Override
    public T resolve(String serviceClass) throws ClassNotFoundException {
        Class<?> clz = Class.forName(serviceClass);
        return (T) this.applicationContext.getBean(clz);
    }
}
